package puzzle.puzzleup2007;

import java.util.ArrayList;
import java.util.List;

/**
 * -2007 Problem 13-
 * @author wong.tong@gmail.com
 *
 */
public class TicTacToe {
	
	public static void main(String[] args) {
		
		List<Point> ps = new ArrayList<Point>();
		for (int x = 0; x < 5; x ++) {
			for (int y = 0; y < 5; y ++) {
				for (int z = 0; z < 5; z ++) {
					ps.add(new Point(x, y, z));
				}
			}
		}
		
		System.out.println(ps.size() + " " + cnt(ps)+"");
	}
	
	private static int num(Point p1, Point p2) {
		for (int i = 4; i > 0; i --) {
			if ((p1.x-p2.x)%i == 0 && (p1.y-p2.y)%i == 0 && (p1.z-p2.z)%i == 0) {
				return i+1;
			}
		}
		return 1;
	}
	
	private static int cnt(List<Point> ps) {
		
		Point p1, p2;
		int n = 0;
		for (int i = 0; i < ps.size(); i ++) {
			p1 = ps.get(i);
			for (int j = i+1; j < ps.size(); j ++) {
				p2 = ps.get(j);
				if (num(p1, p2) == 4) {
					n ++;
				}
			}
		}
		return n;
	}
	
	private static class Point {
		public int x;
		public int y;
		public int z;
		
		public Point(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
		public String toString() { 
			return "(" + x + ", " + y + ", " + z + ")";
		}
	}
}
